<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.incomesrc}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition >
            <h:form id="frmIncomesrc" >
               <script type="text/javascript" >  
                    function handleSaveIncomesrc(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgIncomesrc.hide();  
                        }  
                    }

                    function handleDeleteIncomesrc(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgDelIncomesrc.hide();  
                        }  
                    }
                   

                </script>  

                <p:toolbar>
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}"
                                         icon="ui-icon-document"  rendered="#{menuBean.cekButtonAccess(13,'INS;')}"
                                         action="#{incomesrcBean.newData()}"  
                                         oncomplete="dlgIncomesrc.show()"
                                         process="@this" update=":#{utilityBean.findClientId('displayIncomesrc')}"> 
                            <pe:resetEditableValues for="displayIncomesrc"/>
                        </p:commandButton>
                        <p:commandButton value="#{bundle.btnOpen}" action="#{incomesrcBean.openData()}" oncomplete="dlgIncomesrc.show()"
                                         icon="ui-icon-disk" rendered="#{menuBean.cekButtonAccess(13,'OPN;')}"
                                         update=":#{utilityBean.findClientId('displayIncomesrc')}" > 
                        </p:commandButton>

                        <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash"
					rendered="#{menuBean.cekButtonAccess(13,'DEL;')}"
                                         onclick="dlgDelIncomesrc.show()" /> 
                    </p:toolbarGroup>
                </p:toolbar>
                <br />
                <p:dataTable var="incomesrc" value="#{incomesrcBean.incomesrcs}" id="dtIncomesrcs"
                             selection="#{incomesrcBean.selectedData}" selectionMode="single" resizableColumns="true"
                             rowIndexVar="noUrut"   rowKey="#{incomesrc.incomesrcId}" >
                     <p:column style="width: 10px">
                    <f:facet name="header">No.</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                 </p:column>
                    <p:column style="width:250px" sortBy="#{incomesrc.sourceName}">
                        <f:facet name="header">#{bundle.globalName}</f:facet>
                        <h:outputText value="#{incomesrc.sourceName}" />
                    </p:column>
                </p:dataTable>

                <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                                 header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelIncomesrc">
                    <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnYes}" update="dtIncomesrcs" process="@this"
                                             oncomplete="handleDeleteIncomesrc(xhr, status, args)"  
                                             actionListener="#{incomesrcBean.delete()}" />  
                            <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelIncomesrc.hide()" type="button" /> 
                        </f:facet>
                    </h:panelGrid>
                </p:confirmDialog> 

            </h:form>
            
            <p:dialog header="#{bundle.incomesrc}" widgetVar="dlgIncomesrc" closable="true" dynamic="true" modal="true" appendToBody="true">
                          
                    <p:ajax immediate="true" event="close" listener="#{incomesrcBean.handleClose}"/>
                    <h:form>
                    
                    
                    <h:panelGrid id="displayIncomesrc" columns="2" styleClass="addELIT" >
                        <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.globalName} :" />
                        <h:panelGroup>                            
                            <p:inputText value="#{incomesrcBean.insertedData.sourceName}" rendered="#{incomesrcBean.insertedData != null}" 
                                         required="true" label="#{bundle.globalName}" size="25" />  
                        </h:panelGroup>
                    </h:panelGrid>

                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{incomesrcBean.save()}"
                                             update=":#{utilityBean.findClientId('dtIncomesrcs')}" id="submitIncomesrc" rendered="#{menuBean.cekButtonAccess(13,'UPD;')}"
                                             oncomplete="handleSaveIncomesrc(xhr, status, args)"/>
                            <p:commandButton immediate="true" value="#{bundle.btnClose}" oncomplete="dlgIncomesrc.hide()" icon="ui-icon-document"/>
                        </f:facet>
                    </h:panelGrid>
                        </h:form>
                    <!--<p:defaultCommand target="submitIncomesrc" />-->
                    
                </p:dialog>
            
        </ui:composition>
    </h:body>
</html>
